package com.youdianda.controller.ydd;

import com.youdianda.dto.YddArticlePageDTO;
import com.youdianda.entity.YddArticle;
import com.youdianda.result.Result;
import com.youdianda.service.YddArticleService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: zhaoss
 * @Date: 2023/5/15 - 05 - 15 - 20:20
 * @Description: com.youdianda.controller.admin
 * @version: 1.0
 */
@RestController("adminArticleController")
@RequestMapping("/ydd_article")
@Slf4j
@Api("后端基础数据")
public class ArticleController {
    @Autowired
    private YddArticleService yddArticleService;

    /**
     * 分页查询文章
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public Result page(YddArticlePageDTO dto){
        return yddArticleService.page(dto);
    }

    /**
     * 文章删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result del(String id){
        return yddArticleService.del(id);
    }

    /**
     * 文章添加
     * @param yddArticle
     * @return
     */
    @PostMapping("/add")
    public Result addArticle(@RequestBody YddArticle yddArticle){
        return yddArticleService.addArticle(yddArticle);
    }

    /**
     * 文章详情
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result rowInfo(String id){
        return yddArticleService.rowInfo(id);
    }

    /**
     * 请求参数
     * @param yddArticle
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody YddArticle yddArticle){

        return yddArticleService.update(yddArticle);
    }
}
